<?xml version="1.0" encoding="UTF-8" ?>
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<script type="text/javascript">

$(document).ready(function(){ 
}); 

$('input[name="typeradio"]').on('ifChanged', function(e) {
    var checked = $(this).is(':checked'), val = $(this).val()
    if (checked){
    	if(val=='2'){
    		 $("#tt1").hide();
    		 $("#tt2").show();
    		 $("#tt3").hide();
    	}else if(val=='3'){ 
    		$("#tt1").hide();
   		 	$("#tt2").hide();
   		 	$("#tt3").show();
	   		$("#optiona").val("正确")
	   		$("#optionb").val("错误")
    	}
    }
});

function save(){
	var par="";
	var typeid = $("input[name='typeradio']:checked").val();
	if(typeid=='2'){
		//多选题
		var adIds = "";  
        $("input:checkbox[name=answerbox]:checked'").each(function(i){  
            if(0==i){  
                adIds = $(this).val();  
            }else{  
                adIds += (","+$(this).val());  
            }  
        });  
		par = "?typeId="+typeid+"&answerId="+adIds;
		
	}else if(typeid=='1'){
		//单选题 
		var answerid = $("input[name='answerradio']:checked").val();
		par = "?typeId="+typeid+"&answerId="+answerid;
	}else if(typeid=='3'){
		//判断
		var answerid = $("input[name='pdradio']:checked").val();
		par = "?typeId="+typeid+"&answerId="+answerid;
	}
	
	$("#stForm").attr("action", "answer/tk/addBank.do"+par)
}

function hidec(par){
	if($.trim(par).length == 0){
		$("#an-radio3").attr("disabled",true)
		$("#an-box3").attr("disabled",true)
	}
	if($.trim(par).length != 0){
		$("#an-radio3").attr("disabled",false)
		$("#an-box3").attr("disabled",false)
	}
}
function hided(par){
	if($.trim(par).length == 0){
		$("#an-radio4").attr("disabled",true)
		$("#an-box4").attr("disabled",true)
	}
	if($.trim(par).length != 0){
		$("#an-radio4").attr("disabled",false)
		$("#an-box4").attr("disabled",false)
	}
}
function hidee(par){
	if($.trim(par).length == 0){
		$("#an-radio5").attr("disabled",true)
		$("#an-box5").attr("disabled",true)
	}
	if($.trim(par).length != 0){
		$("#an-radio5").attr("disabled",false)
		$("#an-box5").attr("disabled",false)
	}
}
function hidef(par){
	if($.trim(par).length == 0){
		$("#an-radio6").attr("disabled",true)
		$("#an-box6").attr("disabled",true)
	}
	if($.trim(par).length != 0){
		$("#an-radio6").attr("disabled",false)
		$("#an-box6").attr("disabled",false)
	}
}

</script>
<div class="bjui-pageContent">
	<form method="post" action="answer/tk/addBank.do" id="stForm"  class="pageForm" data-toggle="validate" data-reload-navtab="true">
		<div class="pageFormContent" data-layout-h="0">
			<table class="table table-condensed table-hover">
                <tbody>
					<tr>
						<td><label for="j_dialog_name" class="control-label x85">题目类型：</label>
							<input type="radio" name="typeradio" id="doc-radio1" data-toggle="icheck" data-label="单选题" value="1" checked>
                        	<input type="radio" name="typeradio" id="doc-radio2" data-toggle="icheck" data-label="多选题" value="2">
                        	<input type="radio" name="typeradio" id="doc-radio3" data-toggle="icheck" data-label="判断题" value="3">
                        	<input type="radio" name="typeradio" id="doc-radio4" data-toggle="icheck" data-label="其他" value="9" disabled>
                        	<span style="color:red">*</span>
						</td>
					</tr>
					<tr>
						<td><label for="j_dialog_title" class="control-label x85">题目：</label>
							<input type="text" name="title" data-rule="required" size="35" /><span style="color:red">*</span>
						</td>
					</tr>
					<tr>
						<td><label for="j_dialog_optionA" class="control-label x85">选项A：</label>
							<input type="text" id="optiona" name="optiona" data-rule="required" size="30" /><span style="color:red">*</span>
						</td>
					</tr>
					<tr>
						<td><label for="j_dialog_optionB" class="control-label x85">选项B：</label>
							<input type="text" id="optionb" name="optionb" data-rule="required" size="30" /><span style="color:red">*</span>
						</td>
					</tr>
					<div id="pd">
					<tr>
						<td><label for="j_dialog_optionC" class="control-label x85">选项C：</label>
							<input type="text" name="optionc" size="30" onblur="hidec(this.value);"/>
						</td>
					</tr>
					<tr>
						<td><label for="j_dialog_optionD" class="control-label x85">选项D：</label>
							<input type="text" name="optiond" size="30" onblur="hided(this.value);"/>
						</td>
					</tr>
					<tr>
						<td><label for="j_dialog_optionE" class="control-label x85">选项E：</label>
							<input type="text" name="optione" size="30" onblur="hidee(this.value);"/>
						</td>
					</tr>
					<tr>
						<td><label for="j_dialog_optionF" class="control-label x85">选项F：</label>
							<input type="text" name="optionf" size="30" onblur="hidef(this.value);"/>
						</td>
					</tr>
					</div>
					<tr>
					<td>
						<div id="tt1">
							<label for="j_dialog_name" class="control-label x85">正确答案：</label>
							<input type="radio" name="answerradio" id="an-radio1" data-toggle="icheck" data-label="A" value="a">
	                       	<input type="radio" name="answerradio" id="an-radio2" data-toggle="icheck" data-label="B" value="b">
	                       	<input type="radio" name="answerradio" id="an-radio3" data-toggle="icheck" data-label="C" value="c" disabled>
	                       	<input type="radio" name="answerradio" id="an-radio4" data-toggle="icheck" data-label="D" value="d" disabled>
	                       	<input type="radio" name="answerradio" id="an-radio5" data-toggle="icheck" data-label="E" value="e" disabled>
	                       	<input type="radio" name="answerradio" id="an-radio6" data-toggle="icheck" data-label="F" value="f" disabled>
	                       	<span style="color:red">*</span>
                       	</div>
                       	<div id="tt2"  style="display:none">
						 	<label for="j_dialog_name" class="control-label x85">正确答案：</label>
							<input type="checkbox" name="answerbox" id="an-box1" data-toggle="icheck" data-label="A" value="a">
	                      	<input type="checkbox" name="answerbox" id="an-box2" data-toggle="icheck" data-label="B" value="b">
	                      	<input type="checkbox" name="answerbox" id="an-box3" data-toggle="icheck" data-label="C" value="c" disabled>
	                      	<input type="checkbox" name="answerbox" id="an-box4" data-toggle="icheck" data-label="D" value="d" disabled>
	                      	<input type="checkbox" name="answerbox" id="an-box5" data-toggle="icheck" data-label="E" value="e" disabled>
	                      	<input type="checkbox" name="answerbox" id="an-box6" data-toggle="icheck" data-label="F" value="f" disabled>
	                      	<span style="color:red">*</span>
                    	</div>	
                    	<div id="tt3" style="display:none">
							<label for="j_dialog_name" class="control-label x85">正确答案：</label>
							<input type="radio" name="pdradio" id="pd-radio1" data-toggle="icheck" data-label="正确" value="1">
	                       	<input type="radio" name="pdradio" id="pd-radio2" data-toggle="icheck" data-label="错误" value="0">
	                       	<span style="color:red">*</span>
                       	</div>
                    	<%--<div id="tt4" style="display:none">
							<label for="j_dialog_name" class="control-label x85">正确答案：</label>
							<input type="text" name="answer" data-rule="required" size="30" /><span style="color:red">*</span>
	                       	<span style="color:red">*</span>
                       	</div>
                    --%>
                    	</td>
                      </tr>	
					<tr>
						<td>
						<label for="j_dialog_name" class="control-label x85">状态：</label>
							<select name="status" data-toggle="selectpicker">
	                            <option value="1">启用</option>
	                            <option value="0">关闭</option>
                       	 	</select>
                        	<span style="color:red">*</span>
						</td>
					</tr>
				</tbody>
            </table>
		</div>
		 <div class="bjui-footBar">
            <ul onclick="save()">
                <li><button type="button" class="btn-close">关闭</button></li>
                <li><button type="submit" class="btn-default">保存</button></li>
            </ul>
        </div>
	</form>
</div>